package com.heavenbird.sys.dao.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.heavenbird.book.BookConst;
import com.heavenbird.common.util.DBUtil;
import com.heavenbird.sys.dao.interfaces.ISysStaticDataDAO;
import com.heavenbird.sys.entity.SysStaticData;

public class SysStaticDataDAOImpl implements ISysStaticDataDAO {
	private static transient Log log = LogFactory.getLog(SysStaticDataDAOImpl.class);
	
	public SysStaticData[] querySysStaticData(String codeType,	String codeValue, boolean isValid) throws Exception {
		Session session = DBUtil.getSession();
		Criteria criteria = session.createCriteria(SysStaticData.class);
		criteria.add(Restrictions.eq("codeType", codeType));
		criteria.add(Restrictions.eq("codeValue", codeValue));
		if (isValid) {
			criteria.add(Restrictions.eq("sts", BookConst.SYSSTATICDATA.STS_1));
		}
		List list = criteria.list();
		return (SysStaticData[]) list.toArray(new SysStaticData[list.size()]);
	}

}
